﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GC_School_of_Careers
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            tssl.Text = "GC School of Careers Exam Admission";
        }

        private void loginToolStripMenuItem_Click(object sender, EventArgs e)
        {
//            LoginScreen frm = new LoginScreen();
//            embedForm(frm);
            uclogin frm = new uclogin();
            frm.Visible = true;
            frm.Dock = DockStyle.Fill;
            MainPanel.Controls.Clear();
            MainPanel.Controls.Add(frm);	

        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void embedForm(Form frm)
        {
            // Remove existing form
            foreach (Control ctl in MainPanel.Controls) ctl.Dispose();
            MainPanel.Controls.Clear();
            // Embed new one
            frm.TopLevel = false;
            frm.FormBorderStyle = FormBorderStyle.None;
            frm.Dock = DockStyle.Fill;
            frm.Visible = true;
            frm.StartPosition = FormStartPosition.CenterParent;
            MainPanel.Controls.Add(frm);
        }

        private void studentsToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void studentUCToolStripMenuItem_Click(object sender, EventArgs e)
        {
            checklogin(GlobalUser.GlobalVar);
            ucstudent frm = new ucstudent();
            frm.Visible = true;
            frm.Dock = DockStyle.Fill;
            MainPanel.Controls.Clear();
            MainPanel.Controls.Add(frm);	
        }

        private void MainForm_Load(object sender, EventArgs e)
        {

        }

        private void examinationCenterUCToolStripMenuItem_Click(object sender, EventArgs e)
        {
            checklogin(GlobalUser.GlobalVar);
            ucexaminationcenter frm = new ucexaminationcenter();
            frm.Visible = true;
            frm.Dock = DockStyle.Fill;
            MainPanel.Controls.Clear();
            MainPanel.Controls.Add(frm);	
        }

        private void unitsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            checklogin(GlobalUser.GlobalVar);
            uccentersubjectunit frm = new uccentersubjectunit();
            frm.Visible = true;
            frm.Dock = DockStyle.Fill;
            MainPanel.Controls.Clear();
            MainPanel.Controls.Add(frm);	
        }

        private void userToolStripMenuItem_Click(object sender, EventArgs e)
        {
            checklogin(GlobalUser.GlobalVar);
            ucuser frm = new ucuser();
            frm.Visible = true;
            frm.Dock = DockStyle.Fill;
            MainPanel.Controls.Clear();
            MainPanel.Controls.Add(frm);	
        }

        private void subjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            checklogin(GlobalUser.GlobalVar);
            ucsubject frm = new ucsubject();
            frm.Visible = true;
            frm.Dock = DockStyle.Fill;
            MainPanel.Controls.Clear();
            MainPanel.Controls.Add(frm);	
        }

        private void maintenanceToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void unitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            checklogin(GlobalUser.GlobalVar);
            ucunit frm = new ucunit();
            frm.Visible = true;
            frm.Dock = DockStyle.Fill;
            MainPanel.Controls.Clear();
            MainPanel.Controls.Add(frm);	
        }

        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            checklogin(GlobalUser.GlobalVar);
            ucadministration frm = new ucadministration();
            frm.Visible = true;
            frm.Dock = DockStyle.Fill;
            MainPanel.Controls.Clear();
            MainPanel.Controls.Add(frm);	
        }

        private void applicationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            checklogin(GlobalUser.GlobalVar);
            uctransaction frm = new uctransaction();
            frm.Visible = true;
            frm.Dock = DockStyle.Fill;
            MainPanel.Controls.Clear();
            MainPanel.Controls.Add(frm);	
        }

        private void checklogin(string txtusername)
        {
            if (GlobalUser.GlobalVar == "") 
            {
            MessageBox.Show("Un-authorised login","Error");
            Application.Exit();
            }
        }

        private void unitToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            checklogin(GlobalUser.GlobalVar);
            ucunit frm = new ucunit();
            frm.Visible = true;
            frm.Dock = DockStyle.Fill;
            MainPanel.Controls.Clear();
            MainPanel.Controls.Add(frm);	
        }

        private void reportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            checklogin(GlobalUser.GlobalVar);
            ucreport frm = new ucreport();
            frm.Visible = true;
            frm.Dock = DockStyle.Fill;
            MainPanel.Controls.Clear();
            MainPanel.Controls.Add(frm);	
        }


    }
}
